const Sequelize = require('sequelize');
module.exports = function(sequelize, DataTypes) {
  return sequelize.define('sp_user', {
    user_id: {
      autoIncrement: true,
      type: DataTypes.INTEGER,
      allowNull: false,
      primaryKey: true,
      comment: "自增id"
    },
    username: {
      type: DataTypes.STRING(128),
      allowNull: false,
      defaultValue: "",
      comment: "登录名"
    },
    qq_open_id: {
      type: DataTypes.CHAR(32),
      allowNull: true,
      comment: "qq官方唯一编号信息"
    },
    password: {
      type: DataTypes.CHAR(64),
      allowNull: false,
      defaultValue: "",
      comment: "登录密码"
    },
    user_email: {
      type: DataTypes.STRING(64),
      allowNull: false,
      defaultValue: "",
      comment: "邮箱"
    },
    user_email_code: {
      type: DataTypes.CHAR(13),
      allowNull: true,
      comment: "新用户注册邮件激活唯一校验码"
    },
    is_active: {
      type: DataTypes.ENUM('是','否'),
      allowNull: true,
      defaultValue: "否",
      comment: "新用户是否已经通过邮箱激活帐号"
    },
    user_sex: {
      type: DataTypes.ENUM('保密','女','男'),
      allowNull: false,
      defaultValue: "男",
      comment: "性别"
    },
    user_qq: {
      type: DataTypes.STRING(32),
      allowNull: false,
      defaultValue: "",
      comment: "qq"
    },
    user_tel: {
      type: DataTypes.STRING(32),
      allowNull: false,
      defaultValue: "",
      comment: "手机"
    },
    user_xueli: {
      type: DataTypes.ENUM('博士','硕士','本科','专科','高中','初中','小学'),
      allowNull: false,
      defaultValue: "本科",
      comment: "学历"
    },
    user_hobby: {
      type: DataTypes.STRING(32),
      allowNull: false,
      defaultValue: "",
      comment: "爱好"
    },
    user_introduce: {
      type: DataTypes.TEXT,
      allowNull: true,
      comment: "简介"
    },
    create_time: {
      type: DataTypes.INTEGER,
      allowNull: false,
      comment: "创建时间"
    },
    update_time: {
      type: DataTypes.INTEGER,
      allowNull: false,
      comment: "修改时间"
    }
  }, {
    sequelize,
    tableName: 'sp_user',
    timestamps: false,
    indexes: [
      {
        name: "PRIMARY",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "user_id" },
        ]
      },
    ]
  });
};
